﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace Finance.API.Write.Extensions
{
    public class AbnormalExtensions : IExceptionFilter
    {
        ILogger<AbnormalExtensions> logger;

        public AbnormalExtensions(ILogger<AbnormalExtensions> logger)
        {
            this.logger = logger;
        }

        public void OnException(ExceptionContext context)
        {
            logger.LogError("发生全局异常:" + context.Exception.Message);
            context.ExceptionHandled = true;
        }
    }
}
